Skip to content

Conversation

@sowmyav27
Copy link
Contributor

@sowmyav27 sowmyav27 commented Sep 9, 2025

What issue type does this pull request address? (keep at least one, remove the others)
/kind test

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)
For eng-8321


Note

Adds ordered e2e coverage to validate vCluster→host sync of Service, Endpoints, and EndpointSlice when Endpoints are created before the Service, with setup/cleanup and assertions across both clusters.

  • Tests (e2e):
    • New scenario in test/e2e/servicesync/servicesync.go:
      • Verify vCluster→host sync when Endpoints exist before Service for a headless service.
      • Assert creation and contents of Service, Endpoints, and EndpointSlice in both vCluster and host (labels, ports 80805000, IP 1.1.1.1).
      • Use translated service name via translate.SingleNamespaceHostName and kubernetes.io/service-name selector.
    • Refactors:
      • Suite marked ginkgo.Ordered and describe updated; add BeforeAll/AfterAll to create and cleanup test fixtures.
      • Minor import additions (gomega, fmt, intstr) and validation via gomega.Eventually.

Written by Cursor Bugbot for commit bbd90b9. This will update automatically on new commits. Configure here.

@sowmyav27 sowmyav27 force-pushed the add-test-eng-6661 branch 2 times, most recently from 8f1fb9a to dbc7868 Compare September 10, 2025 00:58
@sowmyav27 sowmyav27 force-pushed the add-test-eng-6661 branch 3 times, most recently from cd0c636 to 49483fb Compare November 3, 2025 14:50
@sowmyav27 sowmyav27 marked this pull request as ready for review November 3, 2025 18:30
@sowmyav27 sowmyav27 requested review from a team as code owners November 3, 2025 18:30

translatedServiceName := translate.SingleNamespaceHostName(serviceName, serviceNamespace, translate.VClusterName)

ginkgo.By("Verify Service exists in Host Cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this is only a check about existence. But is this sufficient? I'd test also the content of the objects. E.g. the presence of the input values from above:

				Ports: []corev1.ServicePort{
				{
					Name:       "custom-port",
					Port:       8080,
					Protocol:   corev1.ProtocolTCP,
					TargetPort: intstr.FromInt(5000),
				},
			},

This also applies to the endpoint object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test wasn't specifically to test it, as the other test was checking the details. But i have added the resource checks also.


ginkgo.Context("Verify endpoint sync when endpoint is deployed before service", func() {
ginkgo.It("Should sync Service, Endpoints, and EndpointSlice from vCluster to host cluster", func() {
ctx := f.Context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: usage of ctx vs. f.Context is not consistent. The object creations use .Create(f.Context, ... and all other use .Get(ctx, ...


ginkgo.By("Create Service Endpoint in vCluster")
_, err := f.VClusterClient.CoreV1().Endpoints(serviceNamespace).Create(f.Context, testEndpoint, metav1.CreateOptions{})
framework.ExpectNoError(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd always prefer gomega.Expect(err).To(gomega.Succeed()) over framework.ExpectNoError(err)` because:

  1. it delivers way more context in case of failure. E.g. the whole nested error chain instead of only the aggregated error message.
  2. it is universal, can be used in any test, not only the once using framework.

But this is personal preference, feel free to just close this comment in case of disagreement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like framework.ExpectNoError is a wrapper for gomega.Expect(err).. So keeping that as is.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@sowmyav27 sowmyav27 force-pushed the add-test-eng-6661 branch 3 times, most recently from 6a0b3b6 to 4759fa8 Compare November 11, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants